package com.hyjiacan.apps.audionly.data.model

import org.junit.jupiter.api.Test
import org.junit.jupiter.api.Assertions.*
import java.util.*

/**
 * TaskInfo实体类的单元测试
 */
class TaskInfoTest {
    @Test
    fun `test TaskInfo creation and property access`() {
        // 创建依赖对象
        val videoFile = VideoFile(
            id = "1",
            name = "test_video.mp4",
            path = "/storage/emulated/0/Download/test_video.mp4",
            duration = 10000,
            size = 5242880,
            format = "mp4"
        )

        val audioParam = AudioParam()
        val createTime = Date()

        // 创建测试对象
        val taskInfo = TaskInfo(
            id = "task1",
            videoFile = videoFile,
            audioParam = audioParam,
            status = TaskInfo.Status.PENDING,
            createTime = createTime
        )

        // 验证属性值
        assertEquals("task1", taskInfo.id)
        assertEquals(videoFile, taskInfo.videoFile)
        assertEquals(audioParam, taskInfo.audioParam)
        assertEquals(TaskInfo.Status.PENDING, taskInfo.status)
        assertEquals(createTime, taskInfo.createTime)
        assertNull(taskInfo.startTime)
        assertNull(taskInfo.endTime)
        assertNull(taskInfo.outputPath)
    }

    @Test
    fun `test TaskInfo status transition`() {
        // 创建测试对象
        val taskInfo = TaskInfo(
            id = "task1",
            videoFile = VideoFile(
                id = "1",
                name = "test_video.mp4",
                path = "/storage/emulated/0/Download/test_video.mp4",
                duration = 10000,
                size = 5242880,
                format = "mp4"
            ),
            audioParam = AudioParam(),
            status = TaskInfo.Status.PENDING,
            createTime = Date()
        )

        // 测试状态转换
        taskInfo.status = TaskInfo.Status.PROCESSING
        assertEquals(TaskInfo.Status.PROCESSING, taskInfo.status)

        taskInfo.status = TaskInfo.Status.COMPLETED
        assertEquals(TaskInfo.Status.COMPLETED, taskInfo.status)
    }

    @Test
    fun `test TaskInfo copy method`() {
        // 创建依赖对象
        val videoFile = VideoFile(
            id = "1",
            name = "test_video.mp4",
            path = "/storage/emulated/0/Download/test_video.mp4",
            duration = 10000,
            size = 5242880,
            format = "mp4"
        )

        val audioParam = AudioParam()
        val createTime = Date()
        val startTime = Date()

        // 创建原始对象
        val original = TaskInfo(
            id = "task1",
            videoFile = videoFile,
            audioParam = audioParam,
            status = TaskInfo.Status.PROCESSING,
            createTime = createTime,
            startTime = startTime,
            outputPath = "/storage/emulated/0/Music/output.mp3"
        )

        // 测试部分属性修改的复制
        val copied = original.copy(
            status = TaskInfo.Status.COMPLETED,
            endTime = Date()
        )

        // 验证复制后的对象
        assertEquals(original.id, copied.id)
        assertEquals(original.videoFile, copied.videoFile)
        assertEquals(original.audioParam, copied.audioParam)
        assertEquals(TaskInfo.Status.COMPLETED, copied.status)
        assertEquals(original.createTime, copied.createTime)
        assertEquals(original.startTime, copied.startTime)
        assertNotNull(copied.endTime)
        assertEquals(original.outputPath, copied.outputPath)
    }
}